package com.ruoyi.related_links.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 爬虫进度响应VO
 *
 * @author lzk
 * @date 2025-06-24
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "爬虫进度响应信息")
public class CrawlerProgressVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 物理主键 */
    @Schema(title = "物理主键")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /** 任务ID */
    @Schema(title = "任务ID", description = "唯一标识爬虫任务的ID")
    private String taskId;

    /** 总数量 */
    @Schema(title = "总数量", description = "需要处理的链接总数量")
    private int totalCount;

    /** 已处理数量 */
    @Schema(title = "已处理数量", description = "已经处理完成的链接数量")
    private int processedCount;

    /** 成功数量 */
    @Schema(title = "成功数量", description = "处理成功的链接数量")
    private int successCount;

    /** 失败数量 */
    @Schema(title = "失败数量", description = "处理失败的链接数量")
    private int failureCount;

    /** 当前批次 */
    @Schema(title = "当前批次", description = "正在处理的批次编号")
    private int currentBatch;

    /** 总批次数 */
    @Schema(title = "总批次数", description = "需要处理的批次总数")
    private int totalBatches;

    /** 状态: RUNNING, COMPLETED, ERROR */
    @Schema(title = "任务状态", description = "任务执行状态：RUNNING-运行中, COMPLETED-已完成, ERROR-错误")
    private String status;

    /** 当前处理项 */
    @Schema(title = "当前处理项", description = "正在处理的链接URL或描述")
    private String currentProcessing;

    /** 开始时间 */
    @Schema(title = "开始时间", description = "任务开始执行的时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    /** 结束时间 */
    @Schema(title = "结束时间", description = "任务结束的时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    /** 错误信息 */
    @Schema(title = "错误信息", description = "任务执行过程中的错误信息")
    private String errorMessage;

    /** 进度百分比 */
    @Schema(title = "进度百分比", description = "任务完成的百分比")
    private double progressPercentage;

    /** 是否已清理 */
    @Schema(title = "是否已清理", description = "进度信息是否已从内存中清理")
    private boolean cleaned;
}